import DrugStatusEnum from "@/enums/DrugStatusEnum";
import { search } from '/src/api/pharmacy/drug'
import { search as drugTypeSearch } from '/src/api/drug/drugType'
import { search as drugUnitSearch } from '/src/api/drug/drugUnit'
import { search as drugDecoctionSearch } from '/src/api/drug/drugDecoction'
import { search as drugSpecificationSearch } from '/src/api/drug/drugSpecification'
import { search as storeSearch } from '/src/api/pharmacy/basis'


/**
 * @param label 表头
 * @param prop 字段名
 * @param isSearch 是否筛选项
 * @type {[{isSearch: boolean, prop: string, label: string},{isSearch: boolean, prop: string, label: string},{isSearch: boolean, prop: string, label: string},{isSearch: boolean, prop: string, label: string, enum: {0: string, 1: string, 2: string}}]}
 */
const tableColumn = [
  {
    label: "药品ID",
    prop: "sub_drug_code",
    isSearch: true,
    formType: "input",
  }, {
    label: "主药品ID",
    prop: "drug_code",
    isSearch: true,
    formType: "input",
  }, {
    label: "药品名称/拼音码",
    prop: "name",
    isSearch: true,
    formType: "input",
  },{
    label: "ID",
    prop: "sub_drug_code",
    isSearch: false,
    isTable: true
  }, {
  label: "药品类型",
  prop: "drug_type_id",
  isForm: true,
  formType: "select",
  required: true,
  asyncSelDataApi: drugTypeSearch,
  asyncSelData: [],
  isChangeFun: true
}, {
  label: "药品类型",
  prop: "drug_type_name",
  isTable: true
},{
  label: "药品渠道",
  prop: "drugstore_id",
  isForm: true,
    isSearch: true,
  formType: "select",
  selectRemoteKey: "name",
  required: true,
  selectRemoteOptions: { },
  asyncSelDataApi: storeSearch,
  asyncSelData: []
}, {
    label: "药品类型",
    prop: "type_id",
    isSearch: true,
    formType: "select",
    required: true,
    asyncSelDataApi: drugTypeSearch,
    asyncSelData: [],
    isChangeFun: true
  }, {
  label: "对应主药品",
  prop: "drug_id",
  isForm: true,
  formType: "select_remote",
  selectRemoteKey: "name",
  required: true,
  selectRemoteOptions: { },
  asyncSelDataApi: search,
  asyncSelData: []
},  {
  label: "药品主名",
  prop: "name",
  isTable: true,
  isForm: true,
  formType: "input",
  required: true,
  min:0,
  max: 50
}, {
  label: "主名拼音全拼",
  prop: "pinyin",
  isForm: true,
  formType: "input",
  required: true,
  min:0,
  max: 50
}, {
  label: "主名拼音简拼",
  prop: "pinyin_abbr",
  isForm: true,
  formType: "input",
  required: true,
  min:0,
  max: 200,
  tips: "可输入多个，请用“,”隔开"
}, {
  label: "药品别名",
  prop: "alias",
  isForm: true,
  formType: "input",
  min:0,
  max: 200,
  tips: "可输入多个，请用“,”隔开"
}, {
  label: "药品别名全拼",
  prop: "alias_spelling",
  isForm: true,
  formType: "input",
  min:0,
  max: 500,
  tips: "可输入多个，请用“,”隔开"
}, {
  label: "药品别名简拼",
  prop: "pinyin_alias",
  isForm: true,
  formType: "input",
  min:0,
  max: 200,
  tips: "可输入多个，请用“,”隔开"
}, {
  label: "药房药品编码",
  prop: "code",
  isTable: true,
  isForm: true,
    isSearch: true,
  required: true,
  formType: "input",
  min:0,
  max: 200,
}, {
  label: "药品状态",
  prop: "status",
  isTable: true,
  isSearch: true,
  formType: "radio",
  defaultValue: 0,
  enum: DrugStatusEnum
},{
    label: "药品单位",
    prop: "unit_name",
    isTable: true,
    formType: "text",
  }, {
  label: "药品单位",
  prop: "unit_id",
  isForm: true,
  formType: "custom",
  required: true,
  children: [{
    label: "药品单位",
    prop: "unit_id",
    formType: "select",
    asyncSelDataApi: drugUnitSearch,
    asyncSelData: [],
  }, {
    label: "支持拆分小数",
    prop: "is_unit_break",
    formType: "checkbox",
  }]
},{
  label: "药品规格",
  prop: "drug_spec_id",
  isTable: true,
  isForm: true,
  formType: "select",
  required: true,
  asyncSelDataApi: drugSpecificationSearch,
  asyncSelData: []
},{
    label: "药品渠道",
    prop: "drugstore_name",
    isTable: true,
    formType: "text",
  },{
  label: "供货价",
  prop: "sup_price",
  isForm: true,
    isTable: true,
  required: true,
  formType: "number",
  min: 1,
  max: 1000,
  tips: "元"
}, {
  label: "零售价",
  prop: "sale_price",
  isForm: true,
    isTable: true,
  required: true,
  formType: "number",
  min: 1,
  max: 1000,
  tips: "元"
},{
  label: "生产厂家",
  prop: "produce_merchant",
  isForm: true,
  required: true,
  formType: "input",
  min: 1,
  max: 200,
}, {
  label: "最大药量",
  prop: "max_use",
  isForm: true,
  formType: "number",
  min: 1,
  max: 1000,
  tips: "g"
},{
  label: "最小药量",
  prop: "min_use",
  isForm: true,
  formType: "number",
  min: 1,
  max: 1000,
  tips: "g"
}, {
  label: "阀值",
  prop: "switch_number",
  isForm: true,
  formType: "number",
  min:0,
  max: 500,
}, {
  label: "创建时间",
  prop: "created_at",
}, {
  label: "创建人",
  prop: "created_name",
}, {
  label: "修改时间",
  prop: "updated_at",
}, {
  label: "修改人",
  prop: "updated_name",
}, {
  label: "备注",
  prop: "remark",
  formType: "textarea",
  min: 0,
  max: 500
}]
const tableConfig = {
  buttons: ["view", "edit", "status", "batchStatus", "downTemplate", "import"],
  total: [
    {label: "药品上架数量", prop: "on_shelf"},
    {label: "药品下架数量", prop: "off_shelf"},
    {label: "药品待上架数量", prop: "go_on_shelf"}],
  statusText: ["上架", "下架"],
  isBatchId: true
}
const pageConfig= {
  small: false,
  disabled: false,
  background: false,
}

export { tableColumn, tableConfig, pageConfig };
